﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XT.Exam.MODEL;
using XT.Exam.IDataAccess;
using System.Data;

namespace XT.Exam.ADO.Net
{
    class AddTestPaperDataAccess: BaseDataAccess<AddTestPaper>, IAddTestPaperDataAccess
    {
        public override string TableName
        {
            get { return "college"; }
        }

        public override Dictionary<string, bool> PkName
        {
            get
            {

                Dictionary<string, bool> dic = new Dictionary<string, bool>();
                dic.Add("college_ID", true);
                return dic;
            }
        }
        public List<AddTestPaper> GetStudentList()
        {
            string sql = @"select a.ID,a.TestPaper_Name,b.College_Name,c.Tie_Name,d.Phase_Name,a.Unit_Name,A.BeginExam,A.EndTime,a.Class_Name,A.TestPaper_State,f.TPStrategy_Name from TestPaper a join College b on a.CollegeID=b.ID
join Tie c on a.TieID=c.ID join PhaseTable d on a.PhaseID=d.ID join TPStrategy f on a.StrategyID=f.ID ";
            DataTable dt = DBHelper.GetDataSet(sql);
            List<AddTestPaper> list = new List<AddTestPaper>();
            foreach (DataRow item in dt.Rows)
            {
                list.Add(new AddTestPaper
                {
                    ID = (Guid)(item["ID"]),
                    TestPaper_Name = item["TestPaper_Name"].ToString(),
                    College_Name = item["College_Name"].ToString(),
                    Tie_Name = item["Tie_Name"].ToString(),
                    Phase_Name = item["Phase_Name"].ToString(),
                    Unit_Name = item["Unit_Name"].ToString(),
                    BeginExam = Convert.ToDateTime(item["BeginExam"]),
                    EndTime = Convert.ToInt32(item["EndTime"]),
                    Class_Name = item["Class_Name"].ToString(),
                    TestPaper_State = (bool)item["TestPaper_State"],
                    TPStrategy_Name = item["TPStrategy_Name"].ToString(),
                });

            }
            return list;
        }
    }
}
